package com.ydy.remote.wechat.vo;

import java.util.Date;

/**
 * { "errcode":0, "errmsg":"ok",
 * "ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA",
 * "expires_in":7200 }
 *
 */
public class JsTicket {
	private String ticket;
	private Long expiresIn;
	private Date createTime;

	public JsTicket() {
		this.createTime = new Date();
	}

	public boolean isExpire() {
		Long now = System.currentTimeMillis();
		Long validDate = getCreateTime().getTime() + ((expiresIn - 100L) * 1000);// -100秒是为了获取token的网络延迟
		return now > validDate;
	}

	public String getTicket() {
		return ticket;
	}

	public void setTicket(String ticket) {
		this.ticket = ticket;
	}

	public Long getExpiresIn() {
		return expiresIn;
	}

	public void setExpiresIn(Long expiresIn) {
		this.expiresIn = expiresIn;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

}
